package com.woniuxy.hrp.service.Serviceimpl;

import com.woniuxy.hrp.entity.Department;
import com.woniuxy.hrp.mapper.DepartmentMapper;
import com.woniuxy.hrp.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: hrph
 * @ClassName DepartmentServiceImpl
 * @description:
 * @author: LRW
 * @create: 2022-08-31 10:28
 * @Version 1.0
 **/
@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;
    /***
     * @description: 根据医院id查所有科室
     * @param: hospitalId
     * @return: java.util.List<com.woniuxy.hrp.entity.Department>
     * @author Lrw
     * @date: 2022/8/31 10:28
     */
    @Override
    public List<Department> getDepartmentsByHospitalId(int hospitalId) {
        return departmentMapper.selectByHospitalId(hospitalId);
    }

    /***
     * @description: 查指定医院所有一级科室
     * @param:
     * @return: java.util.List<com.woniuxy.hrp.entity.Department>
     * @author Lrw
     * @date: 2022/9/4 0:38
     */
    @Override
    public List<Department> getAllParentDepts(int hospId) {
        return departmentMapper.selectAllParentDepts(hospId);
    }

    /***
     * @description: 根据父id查所有二级科室
     * @param: pId
     * @return: java.util.List<com.woniuxy.hrp.entity.Department>
     * @author Lrw
     * @date: 2022/9/4 0:39
     */
    @Override
    public List<Department> getChildrenByPid(int pId) {
        return departmentMapper.selectByPid(pId);
    }
}
